home *** CD-ROM | disk | FTP | other *** search
-
- // Copyright (c) 1999 Macromedia. All rights reserved.
-
- var message = confirm("This command creates a shared palette from multiple files. Select OK and choose a folder of images.");
-
- if (message == true)
- {
- var path = fw.browseForFolderURL("Select Folder");
- var numberOfColors = prompt("Enter the maximum number of colors for the shared palette:","128");
- if (numberOfColors !=null && numberOfColors != 0){
- var listOfFiles = Files.enumFiles(path);
- for (var i in listOfFiles) {
- if (!IsOpenableFile(listOfFiles[i])) {
- listOfFiles[i] = null;
- }
- }
-
- // passing an array of URLs is equivalent to "Open Multiple As Animation"
- var newDoc = fw.openDocument(listOfFiles);
-
- // make sure it's Animated GIF with the right number of colors.
- newDoc.setExportOptions({ exportFormat:"GIF animation", numEntriesRequested:numberOfColors });
- newDoc.rebuildColorTable();
-
- var newPalettePath = fw.browseForFileURL("save", "Save Palette", true);
- if (newPalettePath != null) {
- // saveColorPalette() does not force the correct file extension, so let's do it here.
- newPalettePath = SetExtension(newPalettePath, ".act");
- newDoc.exportOptions.saveColorPalette(newPalettePath);
- newDoc.exportOptions.loadColorPalette(newPalettePath);
- }
-
- }
-
- // -----------------------------------------------------------
-
- function IsOpenableFile(path)
- {
- var gOpenableExtensions = [ ".gif", ".jpg", ".jpeg", ".png", ".psd" ];
- var ext = Files.getExtension(path).toLowerCase();
- for (var i in gOpenableExtensions) {
- if (ext == gOpenableExtensions[i])
- return true;
- }
- return false;
- }
-
- // -----------------------------------------------------------
-
- function SetExtension(pathname, ext)
- {
- var filename = Files.getFilename(pathname, true); // strip extension
- return Files.setFilename(pathname, filename + ext);
- }
-
- }
-
- var result = true;
- result;
-